import 'dart:async';

import 'package:flutter/services.dart';

import 'model/disk_space.dart';
import 'model/memory.dart';


class MemoryInfoPlugin {
  MemoryInfoPlugin();

  static const MethodChannel channel = const MethodChannel('com.nutpi.memory_info');


  static Future<DiskSpace> diskSpace() async {
    try {
      return DiskSpace.fromMap(
        (await channel.invokeMethod('getDiskSpace')).cast<String, dynamic>(),
      );
    } on PlatformException catch (e) {
      throw PlatformException(message: e.message, code: e.code);
    }
  }

  static Future<Memory?> memoryInfo() async {
    try {
      return Memory.fromMap(
        (await channel.invokeMethod('getMemoryInfo')).cast<String, dynamic>(),
      );
    } on PlatformException catch (e) {
      throw PlatformException(message: e.message, code: e.code);
    }
  }

}
